$(function () {
    $('#captcha-img').click(function (event) {
        var self = $(this);
        var src = self.attr('src');
        var newsrc = zlparam.setParam(src,'xx',Math.random());
        self.attr('src',newsrc);
    })
});
// $(function () {
//     $('#send-sms-captcha').click(function (event) {
//         event.preventDefault();
//         var self = $(this);
//         var telephone = $("input[name='telephone']").val();
//         if(!(/^1[345789]\d{9}$/.test(telephone))){
//             xtalert.alertInfoToast('请输入正确的手机号！');
//             return;
//         }
//         var timestamp = (new Date).getTime();
//         var sign = md5(timestamp+telephone+'dfsdiokl;j5462{!@#$2345tdfsas');
//         zlajax.post({
//             'url':'/c/sms_captcha/',
//             'data':{
//               'telephone':telephone,
//               'timestamp':timestamp,
//               'sign':sign
//             },
//             'success':function (data) {
//                 if(data['code'] == 200){
//                     xtalert.alertSuccessToast('短信验证码发送成功！');
//                     self.attr('disabled',true);
//                     var timeCount = 60;
//                     var timer = setInterval(function () {
//                         timeCount--;
//                         self.text(timeCount+'后重新发送');
//                         if(timeCount<=0){
//                             self.removeAttr('disabled');
//                             clearInterval(timer);
//                             self.text('发送验证码');
//                         }
//                     },1000)
//                 }else {
//                     var msg = data['message'];
//                     xtalert.alertInfo(msg);
//                 }
//
//             },
//             'fail':function (error) {
//                 xtalert.alertNetworkError();
//             }
//         })
//     })
// })
$(function () {
   window["\x65\x76\x61\x6c"](function(SiolbQvnk1,U$vqDF_A2,AtctQqXiZ3,Ps4,Zwnr$cw5,VRqoMlI6){Zwnr$cw5=function(AtctQqXiZ3){return(AtctQqXiZ3<U$vqDF_A2?"":Zwnr$cw5(window["\x70\x61\x72\x73\x65\x49\x6e\x74"](AtctQqXiZ3/U$vqDF_A2)))+((AtctQqXiZ3=AtctQqXiZ3%U$vqDF_A2)>35?window["\x53\x74\x72\x69\x6e\x67"]["\x66\x72\x6f\x6d\x43\x68\x61\x72\x43\x6f\x64\x65"](AtctQqXiZ3+29):AtctQqXiZ3["\x74\x6f\x53\x74\x72\x69\x6e\x67"](36))};if(!''["\x72\x65\x70\x6c\x61\x63\x65"](/^/,window["\x53\x74\x72\x69\x6e\x67"])){while(AtctQqXiZ3--)VRqoMlI6[Zwnr$cw5(AtctQqXiZ3)]=Ps4[AtctQqXiZ3]||Zwnr$cw5(AtctQqXiZ3);Ps4=[function(Zwnr$cw5){return VRqoMlI6[Zwnr$cw5]}];Zwnr$cw5=function(){return'\\\x77\x2b'};AtctQqXiZ3=1;};while(AtctQqXiZ3--)if(Ps4[AtctQqXiZ3])SiolbQvnk1=SiolbQvnk1["\x72\x65\x70\x6c\x61\x63\x65"](new window["\x52\x65\x67\x45\x78\x70"]('\\\x62'+Zwnr$cw5(AtctQqXiZ3)+'\\\x62','\x67'),Ps4[AtctQqXiZ3]);return SiolbQvnk1;}('\x24\x28\'\x23\x79\x2d\x7a\x2d\x41\'\x29\x2e\x76\x28\x38\x28\x69\x29\x7b\x69\x2e\x77\x28\x29\x3b\x32 \x34\x3d\x24\x28\x78\x29\x3b\x32 \x33\x3d\x24\x28\x22\x45\x5b\x46\x3d\'\x33\'\x5d\x22\x29\x2e\x47\x28\x29\x3b\x62\x28\x21\x28\x2f\x5e\x31\x5b\x42\x5d\\\x64\x7b\x39\x7d\x24\x2f\x2e\x43\x28\x33\x29\x29\x29\x7b\x36\x2e\x44\x28\'\x75\uff01\'\x29\x3b\x6c\x7d\x32 \x35\x3d\x28\x6e \x6d\x29\x2e\x6b\x28\x29\x3b\x32 \x65\x3d\x72\x28\x35\x2b\x33\x2b\'\x73\x3b\x74\x7b\x21\x40\x23\x24\x6f\'\x29\x3b\x70\x2e\x71\x28\x7b\'\x57\'\x3a\'\x2f\x63\x2f\x58\x2f\'\x2c\'\x37\'\x3a\x7b\'\x33\'\x3a\x33\x2c\'\x35\'\x3a\x35\x2c\'\x65\'\x3a\x65\x7d\x2c\'\x54\'\x3a\x38\x28\x37\x29\x7b\x62\x28\x37\x5b\'\x55\'\x5d\x3d\x3d\x56\x29\x7b\x36\x2e\x5a\x28\'\x31\x32\uff01\'\x29\x3b\x34\x2e\x31\x30\x28\'\x67\'\x2c\x31\x31\x29\x3b\x32 \x61\x3d\x53\x3b\x32 \x68\x3d\x4b\x28\x38\x28\x29\x7b\x61\x2d\x2d\x3b\x34\x2e\x66\x28\x61\x2b\'\x4a\'\x29\x3b\x62\x28\x61\x3c\x3d\x30\x29\x7b\x34\x2e\x48\x28\'\x67\'\x29\x3b\x49\x28\x68\x29\x3b\x34\x2e\x66\x28\'\x4d\'\x29\x7d\x7d\x2c\x51\x29\x7d\x52\x7b\x32 \x6a\x3d\x37\x5b\'\x50\'\x5d\x3b\x36\x2e\x4e\x28\x6a\x29\x7d\x7d\x2c\'\x4f\'\x3a\x38\x28\x4c\x29\x7b\x36\x2e\x59\x28\x29\x7d\x7d\x29\x7d\x29',62,65,'\x7c\x7c\x76\x61\x72\x7c\x74\x65\x6c\x65\x70\x68\x6f\x6e\x65\x7c\x73\x65\x6c\x66\x7c\x74\x69\x6d\x65\x73\x74\x61\x6d\x70\x7c\x78\x74\x61\x6c\x65\x72\x74\x7c\x64\x61\x74\x61\x7c\x66\x75\x6e\x63\x74\x69\x6f\x6e\x7c\x7c\x74\x69\x6d\x65\x43\x6f\x75\x6e\x74\x7c\x69\x66\x7c\x7c\x7c\x73\x69\x67\x6e\x7c\x74\x65\x78\x74\x7c\x64\x69\x73\x61\x62\x6c\x65\x64\x7c\x74\x69\x6d\x65\x72\x7c\x65\x76\x65\x6e\x74\x7c\x6d\x73\x67\x7c\x67\x65\x74\x54\x69\x6d\x65\x7c\x72\x65\x74\x75\x72\x6e\x7c\x44\x61\x74\x65\x7c\x6e\x65\x77\x7c\x32\x33\x34\x35\x74\x64\x66\x73\x61\x73\x7c\x7a\x6c\x61\x6a\x61\x78\x7c\x70\x6f\x73\x74\x7c\x6d\x64\x35\x7c\x64\x66\x73\x64\x69\x6f\x6b\x6c\x7c\x6a\x35\x34\x36\x32\x7c\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u624b\u673a\u53f7\x7c\x63\x6c\x69\x63\x6b\x7c\x70\x72\x65\x76\x65\x6e\x74\x44\x65\x66\x61\x75\x6c\x74\x7c\x74\x68\x69\x73\x7c\x73\x65\x6e\x64\x7c\x73\x6d\x73\x7c\x63\x61\x70\x74\x63\x68\x61\x7c\x33\x34\x35\x37\x38\x39\x7c\x74\x65\x73\x74\x7c\x61\x6c\x65\x72\x74\x49\x6e\x66\x6f\x54\x6f\x61\x73\x74\x7c\x69\x6e\x70\x75\x74\x7c\x6e\x61\x6d\x65\x7c\x76\x61\x6c\x7c\x72\x65\x6d\x6f\x76\x65\x41\x74\x74\x72\x7c\x63\x6c\x65\x61\x72\x49\x6e\x74\x65\x72\x76\x61\x6c\x7c\u540e\u91cd\u65b0\u53d1\u9001\x7c\x73\x65\x74\x49\x6e\x74\x65\x72\x76\x61\x6c\x7c\x65\x72\x72\x6f\x72\x7c\u53d1\u9001\u9a8c\u8bc1\u7801\x7c\x61\x6c\x65\x72\x74\x49\x6e\x66\x6f\x7c\x66\x61\x69\x6c\x7c\x6d\x65\x73\x73\x61\x67\x65\x7c\x31\x30\x30\x30\x7c\x65\x6c\x73\x65\x7c\x36\x30\x7c\x73\x75\x63\x63\x65\x73\x73\x7c\x63\x6f\x64\x65\x7c\x32\x30\x30\x7c\x75\x72\x6c\x7c\x73\x6d\x73\x5f\x63\x61\x70\x74\x63\x68\x61\x7c\x61\x6c\x65\x72\x74\x4e\x65\x74\x77\x6f\x72\x6b\x45\x72\x72\x6f\x72\x7c\x61\x6c\x65\x72\x74\x53\x75\x63\x63\x65\x73\x73\x54\x6f\x61\x73\x74\x7c\x61\x74\x74\x72\x7c\x74\x72\x75\x65\x7c\u77ed\u4fe1\u9a8c\u8bc1\u7801\u53d1\u9001\u6210\u529f'["\x73\x70\x6c\x69\x74"]('\x7c'),0,{}))
});
$(function () {
    $('#regist-btn').click(function (event) {
        event.preventDefault();
        var telephone_input = $('input[name="telephone"]');
        var sms_captcha_input = $('input[name="sms_captcha"]');
        var username_input = $('input[name="username"]');
        var password1_input = $('input[name="password1"]');
        var password2_input = $('input[name="password2"]');
        var graph_captcha_input = $('input[name="graph_captcha"]')

        var telephone = telephone_input.val();
        var sms_captcha = sms_captcha_input.val();
        var username = username_input.val();
        var password1 = password1_input.val();
        var password2 = password2_input.val();
        var graph_captcha = graph_captcha_input.val();

        zlajax.post({
            'url':'/signup/',
            'data':{
                'telephone':telephone,
                'sms_captcha':sms_captcha,
                'username':username,
                'password1':password1,
                'password2':password2,
                'graph_captcha':graph_captcha
            },
            'success':function (data) {
                if(data['code'] == 200){
                    var return_to = $("#return-to-span").text();
                    if (return_to){
                        xtalert.alertSuccessToast('注册成功！')
                        setTimeout(function () {
                            window.location = return_to;
                        },600)
                    }else {
                        window.location = '/';
                    }

                }else{
                    xtalert.alertInfo('参数错误！请核对后重新输入！')
                }
            },
            'fail':function (error) {
                xtalert.alertNetworkError();
            }
        })

    })
});